$(document).ready(function (){
	require([],function (){

		var list_url = "siem/firewall/queryList";
		var list_col = [
		{name:"",text:"" ,hideSearch:"hide",width:3},
		{text:'防火墙名称',name:"fwName",align:"left",width:17},
		{text:'防火墙版本',name:"fwVersion",align:"left",width:16},
		{text:'IP',name:"ip",align:"left",width:16,searchRender:function (el){
			index_render_div(el ,{type:"ip"});
		},hideSearch:true},
		{text:'加入时间',name:"enterDate",align:"left",width:16,searchRender:function(el){
			index_render_div(el ,{type:"date",startKey:"startTime",endKey:"endTime"});
		}},
		{text:'登录提示符',align:"left",width:16,name:"loginPrompt"},
		{text:'',align:'right',width:16,name:'fwId',render : function (text,rowData){
			return '<i class="rh-icon rh-more"></>';
		}}
		];

		var index_oper = [
		{icon:"rh-icon rh-config-strategy",text:'配置策略',aclick:config_strategy},
		{icon:"rh-icon rh-config-ip",text:'配置IP',aclick:config_ip},
		{icon:"rh-icon rh-config-service",text:'配置服务',aclick:config_service},
		{icon:"rh-icon rh-edit" ,text:"修改" ,aclick:update_template_init},
		{icon:"rh-icon rh-delete" ,text:"删除" ,aclick:index_list_delete},
		{icon:"rh-icon rh-stop-use" ,text:"关机" ,aclick:shutdown_firewall},
		{icon:"rh-icon rh-carry-monitor" ,text:"重启" ,aclick:reboot_firewall}
		];

		var add_url = "siem/firewall/addOne";

		var update_url = "siem/firewall/updOne";

		var delete_url = "siem/firewall/deleteOne";

		event_init();

		imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});

		function event_init()
		{
			$("#add_btn").click(function (){
				update_template_init();
			});
		}

		function imp_interface_list(option)
		{
			g_grid.render($("#table_div"),{
				header:list_col,
				oper: index_oper,
				operWidth:"180px",
				url:list_url,
				// data : [{},{}],
				paramObj : option.paramObj,
				isLoad : option.isLoad,
				maskObj : option.maskObj,
				hasBorder : false,
				autoHeight : true,
				showCount : true,
				// cbf : function (){
				// 	var trlist = g_grid.getTrObj($("#table_div"));
				// 	for(var i=0;i<trlist.length;i++){
				// 		var tr = trlist[i];
				// 		$(tr).find('.rh-more').mouseenter(mouseEnter);
				// 		$(tr).find('.rh-more').mouseleave(mouseLeave);
				// 	}
				// 	var timeout;

				// 	function mouseEnter(e){
				// 		var checkMenu = $('.more-menu').length == 0;

				// 		var $menu = $('.more-menu')

				// 		if(checkMenu){
				// 			$menu = $(`<div class="more-menu">
				// 				<div class="more-item" data-id="rh-config-strategy">配置策略</div>
				// 				<div class="more-item" data-id="rh-config-ip">配置IP</div>
				// 				<div class="more-item" data-id="rh-config-service">配置服务</div>
				// 				<div class="more-item" data-id="rh-edit">修改</div>
				// 				<div class="more-item" data-id="rh-delete">删除</div>
				// 				<div class="more-item" data-id="rh-stop-use">关机</div>
				// 				<div class="more-item" data-id="rh-carry-monitor">重启</div>
				// 				</div>`);
				// 			$('body').append($menu);
				// 		}
						
				// 		var offset = $(this).offset();

				// 		$menu.css('top',  (offset.top + 16) + 'px' );
				// 		$menu.css('left',(offset.left - $menu.width()) + 'px' );

				// 		var rowData = $(this).closest('tr').data('data');

				// 		$menu.find('[data-id=rh-config-strategy]').click(function(){
				// 			config_strategy(rowData);
				// 		});
				// 		$menu.find('[data-id=rh-config-ip]').click(function(){
				// 			config_ip(rowData);
				// 		});
				// 		$menu.find('[data-id=rh-config-service]').click(function(){
				// 			config_service(rowData);
				// 		});
				// 		$menu.find('[data-id=rh-edit]').click(function(){
				// 			update_template_init(rowData)
				// 		});
				// 		$menu.find('[data-id=rh-delete]').click(function(){
				// 			index_list_delete(rowData)
				// 		});
				// 		$menu.find('[data-id=rh-stop-use]').click(function(){
				// 			shutdown_firewall(rowData)
				// 		});
				// 		$menu.find('[data-id=rh-carry-monitor]').click(function(){
				// 			reboot_firewall(rowData)
				// 		});

				// 		$menu.mouseleave(function (){
				// 			timeout = setTimeout(function (){
				// 				$('.more-menu').remove();
				// 			},500)
				// 		})

				// 		$menu.mouseenter(function (){
				// 			clearTimeout(timeout);
				// 		})
				// 	}
				// 	function mouseLeave(e){
				// 		timeout = setTimeout(function (){
				// 			$('.more-menu').remove();
				// 		},500)
				// 	}
				// }
			});
		}

		function index_list_delete(rowData)
		{

			g_dialog.operateConfirm("确认删除此记录么" ,{
				saveclick : function()
				{
					um_ajax_post({
						url : delete_url,
						paramObj : rowData,
						successCallBack : function(data){
							imp_interface_list({maskObj : $("#table_div")});
							g_dialog.operateAlert(null ,"操作成功！");
						}
					});
				}
			});
		}
		function topsec_config_strategy(rowData){
			$.ajax({
				type: "GET",
				url: "module/monitor_config/firewall_config_tpl.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=policy_list_template]"),{
						width:"800px",
						init:init,
						saveclick:save_click,
						title: "策略配置"
					});
				}
			});

			function init(el){
				policy_list_init();

				function policy_list_init()
				{
					g_grid.render(el.find("[id=table_div_policy]"),{
						header:[
							/*{text:'名称',name:'name'},*/
							{text:'源IP地址',name:'srcAddr',align:"left"},
							{text:'源服务(端口)',name:'srcPort',align:"left"},
							{text:'目的IP地址',name:'dstAddr',align:"left"},
							{text:'目的服务(端口)',name:'dstPort',align:"left"},
							{text:'动作',name:'action',align:"left"},
							{text:'启用',name:'enable',align:"left"}
						],
						oper: [
							{icon:"rh-icon rh-edit" ,text:"修改" ,aclick:update_policy},
							{icon:"rh-icon rh-delete" ,text:"删除" ,aclick:delete_policy}
						],
						operWidth:"100px",
						url:'/siem/firewall/queryStrategyList',
						paramObj:rowData,
						hideSearch : true,
						paginator : false
					});
				}

				el.find("[id=policy_add_btn]").click(function(){
					update_policy();
				});

				function update_policy(rowData3)
				{
					$.ajax({
						type: "GET",
						url: "module/monitor_config/firewall_config_tpl.html",
						success :function(data)
						{
							g_dialog.dialog($(data).find("[id=policy_edit_template]"),{
								width:"500px",
								init:init,
								saveclick:save_click,
								title: rowData3?"策略配置修改":"策略配置新增"
							});
						}
					});

					function init(cEl)
					{
						g_validate.init(cEl);
						um_ajax_get({
							url:"siem/firewall/queryIPList",
							paramObj:rowData,
							isLoad:true,
							maskObj:"body",
							successCallBack:function(data){
								g_formel.selectEl_render(cEl.find("[data-id=srcAddr]"),{
									data:data,
									text:"name",
									id:"name"
								});
								g_formel.selectEl_render(cEl.find("[data-id=dstAddr]"),{
									data:data,
									text:"name",
									id:"name"
								});
								um_ajax_get({
									url:"siem/firewall/queryPortList",
									paramObj:rowData,
									isLoad:true,
									maskObj:"body",
									successCallBack:function(data1){
										g_formel.selectEl_render(cEl.find("[data-id=srcPort]"),{
											data:data1,
											text:"name",
											id:"name"
										});
										g_formel.selectEl_render(cEl.find("[data-id=dstPort]"),{
											data:data1,
											text:"name",
											id:"name"
										});
										if (rowData3) 
										{
											cEl.find("[data-id=name]").attr("readonly");
											cEl.umDataBind("render",rowData3);
											cEl.find("select").trigger("change");
										}
									}
								});
							}
						});
					}

					function save_click(cEl,cSaveObj)
					{
						if (!g_validate.validate(cEl)) 
						{
							alert();
							return false;
						}
						var url = "siem/firewall/addStrategy";
						var obj = new Object();
						obj.fwStore = rowData;
						obj.fwStrategyStore = cSaveObj;
						if (rowData3) 
						{
							url = "siem/firewall/updStrategy";
						}
						um_ajax_post({
							url:url,
							paramObj:obj,
							isLoad:true,
							maskObj:"body",
							successCallBack:function(data){
								g_dialog.hide(cEl);
								g_dialog.operateAlert(null ,"操作成功！");
								policy_list_init();
							}
						});
					}
				}

				function delete_policy(rowData3)
				{
					g_dialog.operateConfirm("确认删除此记录么?" ,{
						saveclick : function(){
							um_ajax_post({
								url:"siem/firewall/delStrategy",
								paramObj:{fwStrategyStore:rowData3,fwStore : rowData},
								isLoad:true,
								maskObj:"body",
								successCallBack:function(data){
									g_dialog.operateAlert(null ,"操作成功！");
									policy_list_init();
								}
							});
						}
					});
				}
			}

			function save_click(el,saveObj)
			{
				g_dialog.hide(el);
				imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
			}
		}
		function neteye_config_strategy(rowData){
			$.ajax({
				type: "GET",
				url: "module/monitor_config/firewall_config_tpl.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=policy_list_template]"),{
						width:"800px",
						init:init,
						saveclick:save_click,
						title: "策略配置"
					});
				}
			});

			function init(el){
				policy_list_init();

				function policy_list_init()
				{
					g_grid.render(el.find("[id=table_div_policy]"),{
						header:[
							{text:'名称',name:'name'},
							{text:'动作',name:'action',align:"left"},
							{text:'启用',name:'enable',align:"left"}
						],
						oper: [
							{icon:"rh-icon rh-edit" ,text:"修改" ,aclick:update_policy},
							{icon:"rh-icon rh-delete" ,text:"删除" ,aclick:delete_policy}
						],
						operWidth:"100px",
						url:'/siem/firewall/queryStrategyList',
						paramObj:rowData,
						hideSearch : true,
						paginator : false
					});
				}

				el.find("[id=policy_add_btn]").click(function(){
					update_policy();
				});

				function update_policy(rowData3)
				{
					$.ajax({
						type: "GET",
						url: "module/monitor_config/firewall_config_tpl.html",
						success :function(data)
						{
							g_dialog.dialog($(data).find("[id=neteye_policy_edit_template]"),{
								width:"500px",
								init:init,
								saveclick:save_click,
								title: rowData3?"策略配置修改":"策略配置新增"
							});
						}
					});

					function init(cEl)
					{
						g_validate.init(cEl);
						um_ajax_get({
							url:"siem/firewall/queryIPList",
							paramObj:rowData,
							successCallBack:function(data){
								g_formel.selectEl_render(cEl.find("[data-id=srcAddr]"),{
									data:data,
									text:"name",
									id:"name"
								});
								g_formel.selectEl_render(cEl.find("[data-id=dstAddr]"),{
									data:data,
									text:"name",
									id:"name"
								});
								um_ajax_get({
									url:"siem/firewall/queryPortList",
									paramObj:rowData,
									successCallBack:function(data1){
										g_formel.selectEl_render(cEl.find("[data-id=protocolObj]"),{
											data:data1,
											text:"name",
											id:"name"
										});
										if (rowData3) 
										{
											cEl.find("[data-id=name]").attr("readonly");
											// cEl.umDataBind("render",rowData3);
											// cEl.find("select").trigger("change");

											var obj = new Object();
											obj.fwStore = rowData;
											obj.fwStrategyStore = rowData3;
											um_ajax_get({
												url :　"siem/firewall/queryStrategyDetail",
												paramObj : obj,
												successCallBack : function (detailData){
													cEl.umDataBind("render",detailData);
													cEl.find("select").trigger("change");
												}
											});
										}
									}
								});
							}
						});
					}

					function save_click(cEl,cSaveObj)
					{
						if (!g_validate.validate(cEl)) 
						{
							alert();
							return false;
						}
						var url = "siem/firewall/addStrategy";
						cSaveObj.name = 'soc_' + cSaveObj.name;
						var obj = new Object();
						obj.fwStore = rowData;
						obj.fwStrategyStore = cSaveObj;
						if (rowData3) 
						{
							url = "siem/firewall/updStrategy";
						}
						um_ajax_post({
							url:url,
							paramObj:obj,
							isLoad:true,
							maskObj:"body",
							successCallBack:function(data){
								g_dialog.hide(cEl);
								g_dialog.operateAlert(null ,"操作成功！");
								policy_list_init();
							}
						});
					}
				}

				function delete_policy(rowData3)
				{
					g_dialog.operateConfirm("确认删除此记录么?" ,{
						saveclick : function(){
							um_ajax_post({
								url:"siem/firewall/delStrategy",
								paramObj:{fwStrategyStore:rowData3,fwStore : rowData},
								isLoad:true,
								maskObj:"body",
								successCallBack:function(data){
									g_dialog.operateAlert(null ,"操作成功！");
									policy_list_init();
								}
							});
						}
					});
				}
			}

			function save_click(el,saveObj)
			{
				g_dialog.hide(el);
				imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
			}
		}
		function config_strategy(rowData)
		{
			if(rowData.fwVersion == 'topsec'){
				topsec_config_strategy(rowData)
			}else if(rowData.fwVersion == 'neteye'){
				neteye_config_strategy(rowData)
			}
		}

		function config_ip(rowData)
		{
			$.ajax({
				type: "GET",
				url: "module/monitor_config/firewall_config_tpl.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=ip_list_template]"),{
						width:"800px",
						init:init,
						saveclick:save_click,
						title: "IP范围配置"
					});
				}
			});

			function init(el){
				ip_list_init();

				function ip_list_init()
				{
					 g_grid.render(el.find("[id=table_div_ip]"),{
						header:[{text:'名称',name:'name',align:"left"},{text:'起始IP',name:'ip1',align:"left"},{text:'结束IP',name:'ip2',align:"left"}],
						oper: [
							{icon:"rh-icon rh-edit" ,text:"修改" ,aclick:update_ip},
							{icon:"rh-icon rh-delete" ,text:"删除" ,aclick:delete_ip}
						],
						operWidth:"100px",
						url:'siem/firewall/queryIPList',
						paramObj:rowData,
						hideSearch : true,
						paginator : false
					});
				}

				el.find("[id=ip_add_btn]").click(function(){
					update_ip();
				});

				function update_ip(rowData1)
				{
					$.ajax({
						type: "GET",
						url: "module/monitor_config/firewall_config_tpl.html",
						success :function(data)
						{
							g_dialog.dialog($(data).find("[id=ip_edit_template]"),{
								width:"500px",
								init:init,
								saveclick:save_click,
								title: rowData1?"IP配置修改":"IP配置新增"
							});
						}
					});

					function init(aEl)
					{
						g_validate.init(aEl);
						if (rowData1) 
						{
							aEl.find("[data-id=name]").attr("readonly");
							aEl.umDataBind("render",rowData1);
						}
					}

					function save_click(aEl,aSaveObj)
					{
						if (!g_validate.validate(aEl)) 
						{
							return false;
						}
						if (!g_validate.ipValidate(aEl.find("[data-id=ip1]") ,aEl.find("[data-id=ip2]"),[],true))
						{
							return false;
						}
						var url = "siem/firewall/addIP";
						aSaveObj.name = 'soc_' + aSaveObj.name;
						var obj = new Object();
						obj.fwStore = rowData;
						obj.fwIpStore = aSaveObj;
						if (rowData1) 
						{
							url = "siem/firewall/updIP";
						}
						um_ajax_post({
							url:url,
							paramObj:obj,
							isLoad:true,
							maskObj:"body",
							successCallBack:function(data){
								g_dialog.hide(aEl);
								g_dialog.operateAlert(null ,"操作成功！");
								ip_list_init();
							}
						});
					}
				}

				function delete_ip(rowData1)
				{
					g_dialog.operateConfirm("确认删除此记录么?" ,{
						saveclick : function(){
							um_ajax_post({
								url:"siem/firewall/delIP",
								paramObj:{fwIpStore:rowData1,fwStore : rowData},
								isLoad:true,
								maskObj:"body",
								successCallBack:function(data){
									g_dialog.operateAlert(null ,"操作成功！");
									ip_list_init();
								}
							});
						}
					});
				}
			}
			
			function save_click(el,saveObj)
			{
				g_dialog.hide(el);
				imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
			}
		}
		function topsec_config_service(rowData){
			$.ajax({
				type: "GET",
				url: "module/monitor_config/firewall_config_tpl.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=service_list_template]"),{
						width:"600px",
						init:init,
						saveclick:save_click,
						title: "服务配置"
					});
				}
			});

			function init(el){
				service_list_init();

				function service_list_init()
				{
					g_grid.render(el.find("[id=table_div_service]"),{
						header:[{text:'名称',name:'name',align:"left"},{text:'端口1',name:'port1',align:"left"},{text:'端口2',name:'port2',align:"left"},{text : '备注',name : 'comment',align:"left"}],
						oper: [
							{icon:"rh-icon rh-edit" ,text:"修改" ,aclick:update_service},
							{icon:"rh-icon rh-delete" ,text:"删除" ,aclick:delete_service}
						],
						operWidth:"100px",
						url:'/siem/firewall/queryPortList',
						paramObj:rowData,
						hideSearch : true,
						paginator : false
					});
				}

				el.find("[id=service_add_btn]").click(function(){
					update_service();
				});

				function update_service(rowData2)
				{
					$.ajax({
						type: "GET",
						url: "module/monitor_config/firewall_config_tpl.html",
						success :function(data)
						{
							g_dialog.dialog($(data).find("[id=topsec_service_edit_template]"),{
								width:"500px",
								init:init,
								saveclick:save_click,
								title: rowData2?"服务配置修改":"服务配置新增"
							});
						}
					});

					function init(bEl)
					{
						g_validate.init(bEl);
						if (rowData2) 
						{
							bEl.find("[data-id=name]").attr("readonly");
							bEl.umDataBind("render",rowData2);
						}
					}

					function save_click(bEl,bSaveObj)
					{
						if (!g_validate.validate(bEl)) 
						{
							return false;
						}
						if(Number(bEl.find('[data-id=port1]').val()) >Number(bEl.find('[data-id=port2]').val()) ){
							g_dialog.operateAlert(bEl,"开始端口不能大于结束端口",'error');
							return false;
						}
						var url = "siem/firewall/addPort";
						bSaveObj.name = 'soc_' + bSaveObj.name;
						var obj = new Object();
						obj.fwStore = rowData;
						obj.fwPortStore = bSaveObj;
						if (rowData2) 
						{
							url = "siem/firewall/updPort";
						}
						um_ajax_post({
							url:url,
							paramObj:obj,
							isLoad:true,
							maskObj:"body",
							successCallBack:function(data){
								g_dialog.hide(bEl);
								g_dialog.operateAlert(null ,"操作成功！");
								service_list_init();
							}
						});
					}
				}

				function delete_service(rowData2)
				{
					g_dialog.operateConfirm("确认删除此记录么?" ,{
						saveclick : function(){
							um_ajax_post({
								url:"siem/firewall/delPort",
								paramObj:{fwPortStore:rowData2,fwStore : rowData},
								isLoad:true,
								maskObj:"body",
								successCallBack:function(data){
									g_dialog.operateAlert(null ,"操作成功！");
									service_list_init();
								}
							});
						}
					});
				}
			}

			function save_click(el,saveObj)
			{
				g_dialog.hide(el);
				imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
			}
		}
		function neteye_config_service(rowData){
			$.ajax({
				type: "GET",
				url: "module/monitor_config/firewall_config_tpl.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=service_list_template]"),{
						width:"600px",
						init:init,
						saveclick:save_click,
						title: "服务配置"
					});
				}
			});

			function init(el){
				service_list_init();

				function service_list_init()
				{
					g_grid.render(el.find("[id=table_div_service]"),{
						header:[{text:'名称',name:'name',align:"left"},
						{text:'源端口',name:'port1',align:"left"},
						{text:'目的端口',name:'port2',align:"left"},
						{text : '协议',name : 'protocol',align:"left"}],
						oper: [
							{icon:"rh-icon rh-edit" ,text:"修改" ,aclick:update_service},
							{icon:"rh-icon rh-delete" ,text:"删除" ,aclick:delete_service}
						],
						operWidth:"100px",
						url:'/siem/firewall/queryPortList',
						paramObj:rowData,
						hideSearch : true,
						paginator : false
					});
				}

				el.find("[id=service_add_btn]").click(function(){
					update_service();
				});

				function update_service(rowData2)
				{
					$.ajax({
						type: "GET",
						url: "module/monitor_config/firewall_config_tpl.html",
						success :function(data)
						{
							g_dialog.dialog($(data).find("[id=neteye_service_edit_template]"),{
								width:"500px",
								init:init,
								saveclick:save_click,
								title: rowData2?"服务配置修改":"服务配置新增"
							});
						}
					});

					function init(bEl)
					{
						g_validate.init(bEl);
						if (rowData2) 
						{
							bEl.find("[data-id=name]").attr("readonly");
							bEl.umDataBind("render",rowData2);
							var port1 = rowData2.port1;
							var port2 = rowData2.port2;
							bEl.find('[data-id=source_port1]').val(port1.split('-')[0])
							bEl.find('[data-id=source_port2]').val(port1.split('-')[1])
							bEl.find('[data-id=purpose_port1]').val(port2.split('-')[0])
							bEl.find('[data-id=purpose_port2]').val(port2.split('-')[1])
						}
					}

					function save_click(bEl,bSaveObj)
					{
						if (!g_validate.validate(bEl)) 
						{
							return false;
						}
						if(Number(bEl.find('[data-id=source_port1]').val()) >Number(bEl.find('[data-id=source_port2]').val()) ){
							g_dialog.operateAlert(bEl,"开始端口不能大于结束端口",'error');
							return false;
						}
						if(Number(bEl.find('[data-id=purpose_port1]').val()) >Number(bEl.find('[data-id=purpose_port2]').val()) ){
							g_dialog.operateAlert(bEl,"开始端口不能大于结束端口",'error');
							return false;
						}
						bSaveObj.port1 = bEl.find('[data-id=source_port1]').val() + '-' + bEl.find('[data-id=source_port2]').val();
						bSaveObj.port2 = bEl.find('[data-id=purpose_port1]').val() + '-' + bEl.find('[data-id=purpose_port2]').val();
						bSaveObj.name = 'soc_' + bSaveObj.name;
						var url = "siem/firewall/addPort";
						var obj = new Object();
						obj.fwStore = rowData;
						obj.fwPortStore = bSaveObj;
						if (rowData2) 
						{
							url = "siem/firewall/updPort";
						}
						um_ajax_post({
							url:url,
							paramObj:obj,
							isLoad:true,
							maskObj:"body",
							successCallBack:function(data){
								g_dialog.hide(bEl);
								g_dialog.operateAlert(null ,"操作成功！");
								service_list_init();
							}
						});
					}
				}

				function delete_service(rowData2)
				{
					g_dialog.operateConfirm("确认删除此记录么?" ,{
						saveclick : function(){
							um_ajax_post({
								url:"siem/firewall/delPort",
								paramObj:{fwPortStore:rowData2,fwStore : rowData},
								isLoad:true,
								maskObj:"body",
								successCallBack:function(data){
									g_dialog.operateAlert(null ,"操作成功！");
									service_list_init();
								}
							});
						}
					});
				}
			}

			function save_click(el,saveObj)
			{
				g_dialog.hide(el);
				imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
			}
		}
		function config_service(rowData)
		{
			if(rowData.fwVersion == 'topsec'){
				topsec_config_service(rowData)
			}else if(rowData.fwVersion == 'neteye'){
				neteye_config_service(rowData)
			}
		}

		function update_template_init(rowData)
		{
			$.ajax({
				type: "GET",
				url: "module/monitor_config/firewall_config_tpl.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=firewall_update_template]"),{
						width:"500px",
						// btn_array:[
						// 	{id:"firewall_test_btn",class:"dialog-create-workorder",text:"测试",aClick:firewall_test_init}
						// ],
						init:init,
						autoHeight:"autoHeight",
						saveclick:save_click,
						title: rowData?"防火墙配置修改":"防火墙配置新增",
						autoHeight:true
					});
				}
			});

			function init(el)
			{
				el.find("[id=firewall_update_template]").umDataBind("render" ,rowData);	
				el.find("[data-id=loginType]").select2({
					width : '100%'
				});
				el.find("[data-id=fwVersion]").select2({
					width : '100%'
				});
			}

			function firewall_test_init(el)
			{
				var saveObj = el.umDataBind("serialize");
				um_ajax_get({
					url:"AssetOperation/doTestSsh",
					paramObj:saveObj,
					isLoad:true,
					maskObj:"body",
					successCallBack:function(data)
					{
						g_dialog.operateAlert();
					}
				});
			}

			function save_click(el ,saveObj)
			{
				if (!g_validate.validate($("#firewall_update_template")))
				{
					return false;
				}

				else
				{
					var url = rowData?update_url:add_url;
					saveObj.passWord = Encrypt(saveObj.passWord);
					um_ajax_post({
						url : '/siem/firewall/checkTopSecConn',
						paramObj : saveObj,
						maskObj : el,
						successCallBack : function (data){
							if(data == true){
								um_ajax_post({
									url : url,
									paramObj : saveObj,
									maskObj : el,
									successCallBack : function (data){
										g_dialog.operateAlert();
										g_dialog.hide(el);
										imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
									}
								});
							}else {
								g_dialog.operateAlert(el,'配置错误，不能成功连接设备','error');
							}
						}
					});
				}
			}
		}
		function   shutdown_firewall(rowData)
		{
         
            if(rowData.fwVersion =="topsec")
            {
               	g_dialog.operateAlert(null ,"该功能未实现");
            }
            else
        	{
              	um_ajax_post({
						url:"/siem/firewall/shutdown",
						paramObj:rowData,
						isLoad:true,
						maskObj:"body",
						successCallBack:function(data){
							g_dialog.operateAlert(null ,"关机完成！！！");
							imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
						}
				});
        	}

		}
		function reboot_firewall(rowData)
		{ 

            if(rowData.fwVersion =="topsec")
            {
            	g_dialog.operateAlert(null ,"该功能未实现");
            }
            else{
        		um_ajax_post({
						url:"/siem/firewall/restart",
						paramObj:rowData,
						isLoad:true,
						maskObj:"body",
						successCallBack:function(data){
							g_dialog.operateAlert(null ,"重启成功！！");
							imp_interface_list({paramObj:null,isLoad:true,maskObj:"body"});
					}
			});
            }

		}
	});
});